<template>
  <div id="main">
    <div class="header">
      <div class="header-logo text-center">
        <span>通用后台模板</span>
      </div>
      <main-user />
    </div>

    <left-menu />
    <div
      id="content"
      v-if="showData"
    >
      <router-view />
    </div>

  </div>
</template>

<script>
import mainUser from "./components/main-user";
import leftMenu from "./components/left-menu";
import { loginInfo } from "@/api";
import { mapActions } from "vuex";

export default {
  data() {
    return {
      menus: [],
      showData: false
    };
  },
  components: {
    mainUser,
    leftMenu
  },
  methods: {
    ...mapActions("auth", { authUpdate: "updateInfo" }),
    getLoginInfo() {
      loginInfo(res => {
        if (res.code === 1) {
          this.menus = res.data.menus;
          this.authUpdate(res.data);
          this.showData = true;
        }
      });
    }
  },
  created() {
    this.getLoginInfo();
  }
};
</script>

<style lang="scss" scoped>
</style>
